<?php
/**
 * The template for displaying Category pages
 *
 * Used to display archive-type pages for posts in a category.
 *
 * @link http://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage Lebanon_Times
 * @since Lebanon Times 1.0
 */

get_header();
//print "<pre>" . print_r($_REQUEST,TRUE) . "</pre>";exit;
?>

	<div class="row" style="margin-top: 0px;">
		<div class="span3 pull-right">
			<?php lebanontimes_get_right_column(); ?>
		</div>
		<div class="span5 pull-right categoryPosts">
			<div id="postsContainer">
               	<?php 
               	$cat_name = get_category(get_query_var('cat'))->name;

               	$showVideoThumb = FALSE;
               	if (preg_match("/فيديو/", $cat_name)) {
               		$showVideoThumb = TRUE;
               	}
               	?>
               	<h1><?php echo $cat_name;?></h1>

               	<?php 
               	query_posts($query_string);

				if ( have_posts() ) : ?>
				<ul>
					<?php
					/* Start the Loop */
					while ( have_posts() ) : the_post();
					?>
						<li>
							<?php 
							if ($showVideoThumb) { 
								// this is where the custom field prints images for each post
								$values = get_post_custom_values("video_id");
								if (!empty($values)) { ?>
							<div class="thumbnail">
		                        <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
		                            <img src="http://i.ytimg.com/vi/<?php echo $values[0]; ?>/0.jpg" width='130' alt="<?php the_title(); ?> Thumbnail" />
		                            <img src="<?php echo get_template_directory_uri(); ?>/images/red-play-btn.png" class="play-button">
		                        </a>
		                    </div>
		                    <?php 
		                    	}
		                	} ?>
							<a href="<?php the_permalink() ?>" target="_parent">
								<?php the_title(); ?>
							</a>
						</li>
					<?php
					endwhile;

					lebanontimes_content_nav( 'nav-below' );
					?>
				</ul>
				<?php else : ?>
					<?php get_template_part( 'content', 'none' ); ?>
				<?php endif; ?>
			</div>
		</div>
		<div class="span3 pull-right">
			<?php lebanontimes_get_left_column(); ?>
		</div>
	</div>
<?php get_footer(); ?>